products =  [['iphone',6888],['MacPro',14800],['小米6',2499],['Coffee',31],['Book',60],['Nike',699]]
name = []
cost = []
shop_car = []
shop_cost = []
#---------商品列表打印------------
print('-' * 6+' '+'商品列表'+' '+'-'*6)
for i in range(len(products)):
    temp1 = name.append(products[i][0])
    temp2 = cost.append(products[i][1])
    print(name[i],cost[i],sep=" "*6)
    if i >5:
        break
#---------购物车添加------------
flag = True
while flag:
    buy = input('what do you want buy:')
    if buy in name :
        a = name.index(buy) # buy = ipone = 0
        b = name[a]   # a = name[0] = ipone
        c = cost[a]   # c = cost[0] = 6888
        shop_car.append(b)
        shop_cost.append(c)
    elif buy in 'q,Q':
        flag = False
        print('thank you for shopping')
        print(shop_car,sum(shop_cost))
        break
    elif buy not in name:
        print('If you want to end the purchase, please enter Q')
        continue

#当使用非ASCII码时要在前面，具体可以看报错提示的pep-0263，另外完成作业要认真